package com.happyclub.paul.service.impl;

import com.happyclub.paul.dao.ManualAuditRepostitory;
import com.happyclub.paul.service.ManualAuditService;
import com.happyclub.pojo.TbManualAudit;
import com.happyclub.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @Auther: 魏泉琦
 * @Date: 2019/4/12 09:26
 * @Description: 人工审核
 */
@Service
public class ManualAuditServiceImpl implements ManualAuditService {


    @Autowired
    private ManualAuditRepostitory manualAuditRepostitory;

    /**
     *@Description: 保存审核人的信息
     *@Author: 魏泉琦
     *@date: 2019/4/12
     */
    @Transactional
    @Override
    public Integer createManualAudit(String artId,String photoId,String autMan,long isOk,String auditManName) {
        Integer cnt = manualAuditRepostitory.createManualAudit(artId, photoId, autMan, isOk, auditManName);
        return cnt;
    }

    /**
     *@Description: 展示人工审核的审核人的审核信息
     *@Author: 魏泉琦
     *@date: 2019/4/12
     */
    @Override
    public JsonResult showManualAudits() {
        JsonResult jsonResult = new JsonResult();
        try{
            List<TbManualAudit> manualAudits = manualAuditRepostitory.findAll();
            if(null==manualAudits || manualAudits.size()==0){
                jsonResult.setMsg("展示没有数据");
                jsonResult.setErrorCode("NO");
                return jsonResult;
            }
            jsonResult.setResult(manualAudits);
        }catch (Exception e){
            jsonResult.setMsg("网络异常");
            jsonResult.setErrorCode("error");
            e.printStackTrace();
            return jsonResult;
        }

        return jsonResult;
    }
}
